<%- include('../header') %>
<head>
    <script src="/javascripts/netdisk.js"></script>
    <link rel="stylesheet" href="/stylesheets/netdisk.css">
</head>
<div class="modal fade" id="UploadBox" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel">文件盒</h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    <div style="display:flex;justify-content:space-between;width:100%"><label>上传文件</label>
                    <a class='btn btn-primary btn-sm' href="javascript:upload_file();">确认</a></div>
                    <input id='my_upload' type='file' name='upload_single'/>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="container" style="margin-top:30px;">
    <div style="display:flex;justify-content:space-between;align-items:center;">
        <h2>所有历史版本</h2>
        <p>上传的文件名称只能是英文，内容也必须是英文。区分大小写！</p>
        <div style="display:flex">
            <p style="padding:5px"><a class="btn btn-primary" href="/netdisk/dlcur">下载当前版本</a></p>
            <p style="padding:5px"><a class="btn btn-primary" href="#" data-toggle="modal" data-target="#UploadBox">上传数据库文件</a></p>
        </div>
    </div>
    <table>
    <thead><tr><th>名称</th><th>文件大小</th><th>修改时间</th><th>操作</th></tr></thead>
    <tbody>
    <% if(files.length > 0) { %>
    <% files.forEach(f=>{ %>
    <tr>
        <td style="text-align:left;">
            <a href="/netdisk?path=<%=path+'/'+f.name%>"><%=f.name%></a>
        </td>
        <td>
            <% if(f.isFile()) { %>
                <%= f.size>1024*1024?Math.trunc(f.size/1048576)+"MB":(f.size>1024?Math.trunc(f.size/1024)+"KB":f.size+"B") %>
            <% } else { %>
                -
            <% } %>
        </td>
        <td>
            <a href="#" data-toggle="tooltip" data-placement="bottom" title="<%= '访问: '+f.atime+'\r\n修改: '+f.mtime+'\r\n创建: '+f.ctime%>"><%= f.mtime%></a>
        </td>
        <td>
            <a href="javascript:rename('<%=path%>/<%=f.name%>')">重命名</i></a>
            <a style="color:red" href="javascript:del('<%=path+'/'+f.name%>')">删除</a>
        </td>
    </tr>
    <%}); } else {%>
    <tr>
        <td style="text-align:left">(没有文件)</td><td></td><td></td><td></td>
    </tr>
    <%}%>
    </tbody></table>
</div>
<%- include('../footer') %>
